#include "comm.h"
using namespace std;

int main()
{
    //写端

    //1.打开文件
    int wfd = open(Path,O_WRONLY);
    if (wfd < 0)
    {
        cerr << "open failed, errno: " << errno << ", errstring: " << strerror(errno) << endl;
        return 1;
    }

    //2.写东西进去
    string buffer;
    while(1)
    {
        cout << "Please Enter Your Message ";
        getline(cin,buffer);
        if(buffer == "quit") break;
        ssize_t n = write(wfd,buffer.c_str(),buffer.size());
        if(n < 0)
        {
            cout << "write fail"<< " "<< "errno:" << errno << "errorstring:" << strerror(errno) << endl;
            break;
        }
    }
    close(wfd);
    return 0;
}
